package com.lingmeng.common.core.exception;

import com.lingmeng.common.core.constant.Constants;
import com.lingmeng.common.core.constant.HttpStatus;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 用来代替大部分Exception(试用)
 */
@Getter
@Setter
@Accessors(chain = true)
public class LingmengException extends RuntimeException {

	private static final long serialVersionUID = 1L;
	protected Integer code = HttpStatus.SUCCESS;
	protected String message;
	protected String detailMessage;

	public LingmengException() {
	}

	public LingmengException(String message) {
		this(message, Constants.FAIL, null);
	}

	public LingmengException(String message, Integer code) {
		this(message, code, null);
	}

	public LingmengException(String message, Integer code, String detailMessage) {
		this.code =	code;
		this.message = message;
		this.detailMessage = detailMessage;
	}

	public LingmengException(Throwable e) {
		super(e.getMessage(), e);
		this.message = e.getMessage();
	}


	@Override
	public String getMessage() {
		return message;
	}
}
